package com.sunchangpeng.servletasync.web.controller;

import com.sunchangpeng.servletasync.service.PushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.async.DeferredResult;

/**
 * Created by sunchangpeng
 */
@Controller
public class IndexController {
    @Autowired
    private PushService pushService;

    @RequestMapping("/")
    public String index() {
        return "index";
    }

    @RequestMapping("/defer")
    @ResponseBody
    public DeferredResult<String> deferredCall() {
        return pushService.getAsynUpdate();
    }
}
